<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds"
	debug="false">
	<contextName>logback</contextName>
	<#if frameWorkVal=="ssm">
	<substitutionProperty name="logbase" value="<#noparse>${</#noparse>catalina.base}" />
	</#if>
	<!--输出到控制台 -->
	<appender name="console"
		class="ch.qos.logback.core.ConsoleAppender">
		<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>ERROR</level> 
			</filter> -->
		<encoder>
			<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
			</pattern>
		</encoder>
	</appender>

	<!--按天生成日志 -->
	<appender name="logFile"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<Prudent>true</Prudent>
		<rollingPolicy
			class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<#if frameWorkVal=="ssm">
			<FileNamePattern><#noparse>${</#noparse>logbase}/unsuallog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log</FileNamePattern>
			</#if>
			<#if frameWorkVal=="springBoot">
			<FileNamePattern>log/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log</FileNamePattern>
			</#if>
		</rollingPolicy>
		<layout class="ch.qos.logback.classic.PatternLayout">
			<Pattern>
				%d{yyyy-MM-dd HH:mm:ss} -%msg%n
			</Pattern>
		</layout>
	</appender>

	<!--错误日志统一输出到这里 -->
	<appender name="error"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<rollingPolicy
			class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<!--日志文件输出的文件名 -->
			<#if frameWorkVal=="ssm">
			<FileNamePattern><#noparse>${</#noparse>logbase}/errorlog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log</FileNamePattern>
			</#if>
			<#if frameWorkVal=="springBoot">
			<FileNamePattern>errorlog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log</FileNamePattern>
			</#if>
			<!--日志文件保留天数 -->
			<MaxHistory>365</MaxHistory>
		</rollingPolicy>
		<encoder
			class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<!--格式化输出：%d表示日期，%thread表示线程名，%-5level：级别从左显示5个字符宽度%msg：日志消息，%n是换行符 -->
			<pattern> %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n</pattern>
		</encoder>
		<!--日志文件最大的大小 -->
		<triggeringPolicy
			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
			<MaxFileSize>10MB</MaxFileSize>
		</triggeringPolicy>
		<!-- 所有error日志都在这里 -->
		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<!-- mybatis打印sql语句 -->
	<logger name="${packageName}.dao" level="DEBUG"/>

	<root level="INFO">
		<appender-ref ref="console" />
		<appender-ref ref="logFile" />
		<appender-ref ref="error"/>
	</root>
	
</configuration>